<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>小区app用户列表</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!--<link rel="stylesheet" type="text/css" href="../bootstrap/dist/css/bootstrap.min.css"/>-->
		<link rel="stylesheet" type="text/css" href="../bootstrap/dist/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="../new_css/bootstrap-datetimepicker.min.css" />
		<!--<link rel="stylesheet" type="text/css" href="css/public.css" />-->
	</head>
	<style type="text/css">
		.remove {
			cursor: pointer;
		}
		
		.remove:hover {
			color: red;
		}
		
		.pagination span {
			font: 14px/34px "";
			padding: 0 5px;
		}
		
		.form-control {
			display: inline-block;
			width: 150px;
		}
		
		.search {
			width: 220px;
		}
		
		.header {
			/*border-bottom: 1px solid #fefefe;*/
		}
		
		.header span {
			padding: 0 5px;
		}
		
		.table_cla {
			height: 560px;
		}
	</style>

	<body>
		<div id="app" style="width: 100%; margin: 0 auto;padding:0 20px;">
			<div class="header" style="margin-top: 20px;">
				<!--<span>开始时间:</span><input class="time-input form-control" type="text" id="datetimepicker" v-model="start">				
				<span>结束时间:</span><input class="time-input form-control" type="text" id="datetimepicker1" v-model="end">-->
				<select name="" id="select_1" class="form-control" v-model="area_model">
					<option value="">请选择小区</option>
					<option v-for="index in area" :value="index.areaid" v-text="index.areaname"></option>
				</select>
				<input type="text" class="form-control search" name="search1" id="search1" value="" v-model="searchmain" placeholder="根据昵称/注册电话搜索" />

				<button type="button" class="btn btn-info " data-dismiss="modal" @click="search('')">搜索</button>
				<!--<button type="button" class="btn btn-info" data-dismiss="modal" @click="addMensuo">增加</button>-->
			</div>
			<div class="table_cla">
				<table class="table">
					<caption>小区app用户列表</caption>
					<thead>
						<tr>
							<th>小区</th>
							<th>昵称</th>
							<th>注册电话</th>
							<!--<th>id</th>-->
							<th>注册时间</th>
							<th>最后一次操作时间</th>
						</tr>
					</thead>
					<tbody>
						<tr v-for="(tt,index) in table">
							<td v-text="tt.area_name"></td>
							<td v-text="tt.nickname"></td>
							<td v-text="tt.mobileno"></td>
							<!--<td v-text="tt.id"></td>-->
							<td v-text="tt.createdate"></td>
							<td v-text="tt.invalidtime"></td>
						</tr>						
					</tbody>
				</table>

			</div>
			<ul class="pagination">
				<span v-text="count_all"></span>
				<!--<li v-show="current != 1" @click="current-- && goto(current--)">
					<a href="#">上一页</a>
				</li>-->
				<li v-for="index in pages" @click="goto(index)" :class="{'active':current == index}" :key="index">
					<a href="#" v-text="index"></a>
				</li>
				<!--<li v-show="allpage != current && allpage != 0 " @click="current++ && goto(current++)">
					<a href="#">下一页</a>
				</li>-->
				<span>跳到:</span>
				<!--<input style="width: 50px;height: 34px;" min="1" max="{{allpage}}" type="number" name="goto" id="goto" v-model="jump" />-->
				<input style="width: 50px;height: 28px;" name="goto" id="goto" v-model="jump" type="text" name="" oninput="value=value.replace(/[^\d]/g,'')">
				<span>页</span>
				<button type="button" id="gotoo" @click="goto(jump)" class="btn btn-danger ">确定 </button>
			</ul>

			<!-- 模态框（Modal）提示信息 -->
			<div class="modal fade" id="myModal_tips" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title" id="myModalLabel">提示信息</h4>
						</div>
						<div class="modal-body" id="tips" v-text="tips_modal">

						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						</div>
					</div>
				</div>
			</div>
		</div>

	</body>

</html>
<script src="../new_js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../new_js/vue.js" type="text/javascript" charset="utf-8"></script>
<script src="../bootstrap/dist/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../new_js/bootstrap-datetimepicker.js" type="text/javascript" charset="utf-8"></script>
<script src="../new_js/bootstrap-datetimepicker.zh-CN.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/public.js" type="text/javascript" charset="utf-8"></script>
<script>
	new Vue({
		el: '#app',
		data: {
			val_te: "",
			urltest: "",
			userId: "",
			current: 1,
			fullname: "",
			showItem: 5,
			allpage: "",
			userName: "",
			jump: "",
			page_show: false,
			tips_modal: "",
			count_all: "",
			areaid: "",
			start: "",
			end: "",
			searchmain: "",
			panduan: "",
			merchantid: "",

			leixing_model: "",
			removeid: "",
			area: [{
				areaname: '请选择小区',
				areaid: ""
			}],
			area_model: "",
			area_name:"",
			table: [{

				},

			]
		},
		//计算属性
		computed: {

		},
		created: function() {

		},
		mounted: function() {
			var that = this;
			var userId = sessionStorage.getItem("userId");

			if(userId == "" || userId == undefined || userId == null) {
				top.location.href = "../login.html";
			} else {
				that.urltest = sessionStorage.getItem("urltest");
				that.userId = sessionStorage.getItem("userId");
				that.fullname = sessionStorage.getItem("fullname");
				that.userName = sessionStorage.getItem("userName");
				that.datePickerInit();
				that.area_model = this.area[0].areaid;
				that.area_info()
			}

		},
		computed: {
			pages: function() {				
				var pag = [];
				if(this.current < this.showItem) { //如果当前的激活的项 小于要显示的条数
					//总页数和要显示的条数那个大就显示多少条
					var i = Math.min(this.showItem, this.allpage);
					while(i) {
						pag.unshift(i--);
					}
				} else { //当前页数大于显示页数了
					var middle = this.current - Math.floor(this.showItem / 2), //从哪里开始
						i = this.showItem;
					if(middle > (this.allpage - this.showItem)) {
						middle = (this.allpage - this.showItem) + 1
					}
					while(i--) {
						pag.push(middle++);
					}
				}
				return pag
			},

		},
		methods: {
			//获取小区			
			area_info: function() {
				var that = this;
				var data = JSON.stringify({
					requestString: '',
					userId: that.userId,
					fullname: that.fullname
				});
				$.ajax({
					contentType: "application/json; charset=utf-8",
					type: "POST",
					url: that.urltest + "/verify/financial/selectAreaNameList",
					data: data,
					async: true,
					dataType: "json",
					success: function(msg) {
						if(msg.responseCode == 200) {
							var aa = JSON.parse(msg.returnString);
							that.area = aa;
						} else {
							//							alert(msg.disp)
							that.tips_modal = msg.resoponseDisp;
							$('#myModal_tips').modal('show');
						}
					},
					error: function() {
						//						alert("获取信息失败");
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
					}
				});
			},
			//日期初始化
			datePickerInit: function() {		
				var d, s;
				var self = this;
				self.start = s;
				$('#datetimepicker').datetimepicker({
					minView: "month", //选择日期后，不会再跳转去选择时分秒 
					language: 'zh-CN',
					format: 'yyyy-mm-dd',
					todayBtn: 1,
					autoclose: 1,
				});
				$('#datetimepicker1').datetimepicker({
					startDate: s,
					minView: "month", //选择日期后，不会再跳转去选择时分秒 
					language: 'zh-CN',
					format: 'yyyy-mm-dd',
					todayBtn: 1,
					autoclose: 1,
				});
				$('#datetimepicker').datetimepicker()
					.on('hide', function(ev) {
						var value = $("#datetimepicker").val();
						self.start = value;
						$('#datetimepicker1').datetimepicker('setStartDate', self.start);
						self.end = "";
					});
				$('#datetimepicker1').datetimepicker()
					.on('hide', function(ev) {
						var value = $("#datetimepicker1").val();
						self.end = value;

					});
			},
			search: function(info) {
				var that = this;				
				that.area_name = $("#select_1  option:selected").text();				
				if(info == '') {
					var data = JSON.stringify({
						requestString: JSON.stringify({
							pageSize: 10,
							pageNumber: 1,
							areaid: that.area_model,
							selectinfo: that.searchmain
						}),
						userId: that.userId,
						fullname: that.fullname
					});
				} else {
					var data = info
				}

				$.ajax({
					contentType: "application/json; charset=utf-8",
					type: "POST",
					url: that.urltest + "/verify/financial/selectAPPUserForArea",
					data: data,
					async: true,
					dataType: "json",
					success: function(msg) {
						if(msg.responseCode == 200) {
							console.log(msg)
							var msgg = JSON.parse(msg.returnString);
							if(msgg.length==0){
								that.tips_modal = "暂无数据";
								$('#myModal_tips').modal('show');
							}
							for(var i = 0; i < msgg.length; i++) {
								msgg[i].area_name=that.area_name
							}	
							that.table = msgg;
//							that.count_all = "共" + msg.count + "条";
							var yu = msg.count % 10;
							if(yu == 0) {
								that.allpage = parseInt(msg.count / 10);
							} else {
								that.allpage = parseInt(msg.count / 10) + 1;
							}
							that.count_all = "共" + msg.count + "条 "+ " 共" + that.allpage + "页";
						} else {
							//							alert(msg.disp)
							that.tips_modal = msg.resoponseDisp;
							$('#myModal_tips').modal('show');
						}
					},
					error: function() {
						//						alert("获取信息失败");
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
					}
				});

			},
			goto: function(index) {
				if(index == this.current) return;
				if(index > this.allpage) {
					return
				}
				var re = /^[1-9]+[0-9]*]*$/ //判断正整数      // /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字  
				if(!re.test(index)) {
					return false;
				}
				this.current = index;
				var data = JSON.stringify({
					requestString: JSON.stringify({
						pageSize: 10,
						pageNumber: index,
						areaid: this.area_model,
						selectinfo: this.searchmain
					}),
					userId: this.userId,
					fullname: this.fullname
				});
				this.search(data)
			}

		},

	})
</script>